<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 了解 -->
      <h2>组件使用v-model</h2>
      <p>{{ value }}</p>
      <!-- <child :value="value" @get-value="(v) => value = v"></child> -->
      <!-- <child :model-value="value" @update="(v) => value = v"></child> -->
      <child v-model:model-value="value"></child>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        props: {
          modelValue: String,
        },
        template: `
          <div>
            child组件 
            <input type="text" :value="modelValue" @input="$emit('update:model-value', $event.target.value)" />
          </div>
        `,
      };

      createApp({
        data() {
          return {
            value: "abc",
          };
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
